package com.dawn.interestmanage.serviceimpl;

import com.dawn.interestmanage.bean.InterestinfoBean;
import com.dawn.interestmanage.dao.InterestinfoDao;
import com.dawn.interestmanage.service.InterestinfoService;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
 
import com.dawn.usermanage.bean.UserBean;
import com.dawn.usermanage.dao.UserManageDao;
import com.dawn.utils.exceptions.DaoAccessException;

@Service
public class InterestinfoServiceImpl implements InterestinfoService {

	private static Logger logger = Logger.getLogger(InterestinfoServiceImpl.class);
	
    @Autowired
    private InterestinfoDao interestinfoDao;
	   
	@Override
	public InterestinfoBean findInterByIid(int interestId) {
		// TODO Auto-generated method stub
	    List<InterestinfoBean> interests = interestinfoDao.findInterByIid(interestId);
        if(!interests.isEmpty()){
        	InterestinfoBean interest = interests.get(0);
            return interest;
        }
		return null;
	}

	@Override
	public InterestinfoBean findInterByIName(String interestName) {
		// TODO Auto-generated method stub
		List<InterestinfoBean> interests = interestinfoDao.findInterByIName(interestName);
        if(!interests.isEmpty()){
        	InterestinfoBean interest = interests.get(0);
            return interest;
        }
		return null;
	}
	
	@Override
	public List<InterestinfoBean> findAllInter()
	{
		List<InterestinfoBean> interests = interestinfoDao.findAllInter();
        if(!interests.isEmpty()){
            return interests;
        }
		return null;
	}
	
	@Override
    public int AddInterest(InterestinfoBean ib)
	{
		interestinfoDao.addInterest(ib);
		return 1;
		
	}
	
	@Override
    public int DelInterest(InterestinfoBean ib)
	{
		interestinfoDao.delInterest(ib);
		return 1;
		
	}

}
